﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:CodeReason.Reports.Controls"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type local:BusyDecorator}">
        <Setter Property="BusyStyle">
            <Setter.Value>
                <Style TargetType="{x:Type Control}">
                    <Setter Property="Width" Value="100" />
                    <Setter Property="Height" Value="100" />
                    <Setter Property="HorizontalAlignment" Value="Center" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Control}">
                                <ControlTemplate.Resources>
                                    <Storyboard x:Key="SpinAnimation" RepeatBehavior="Forever">
                                        <DoubleAnimation To="1" Duration="0:0:1"
                                                    Storyboard.TargetName="content"
                                                    Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation From="0" To="359" Duration="0:0:3" RepeatBehavior="Forever"
                                                    Storyboard.TargetName="angle"
                                                    Storyboard.TargetProperty="Angle"/>
                                    </Storyboard>
                                </ControlTemplate.Resources>
                                <Canvas x:Name="canvasBusy" Margin="0,0,0,0" Width="1" Height="1">
                                    <Canvas.RenderTransform>
                                        <TransformGroup>
                                            <RotateTransform x:Name="angle" Angle="0" CenterX="0.5" CenterY="0.5"/>
                                            <TranslateTransform X="-0.5" Y="-0.5"/>
                                            <ScaleTransform x:Name="scaleTransform" ScaleX="64" ScaleY="64"/>
                                        </TransformGroup>
                                    </Canvas.RenderTransform>
                                    <Canvas Name="content" Opacity="0">
                                        <Path Width="1" Height="1" Stretch="Fill" Stroke="Black" Opacity="0.5" StrokeThickness="0.1" StrokeStartLineCap="Round">
                                            <Path.Data>
                                                <PathGeometry>
                                                    <PathFigure StartPoint="1,0">
                                                        <ArcSegment Point="0,-1" RotationAngle="90" SweepDirection="Clockwise" IsLargeArc="True" Size="1,1"/>
                                                    </PathFigure>
                                                </PathGeometry>
                                            </Path.Data>
                                        </Path>
                                        <Path Canvas.Left="0.5" Canvas.Top="-0.1" Width="0.4" Height="0.4" Opacity="0.5" Stretch="Fill" Fill="Black">
                                            <Path.Data>
                                                <PathGeometry>
                                                    <PathFigure StartPoint="0,-1.1">
                                                        <LineSegment Point="0.1,-1" />
                                                        <LineSegment Point="0,-0.9" />
                                                    </PathFigure>
                                                </PathGeometry>
                                            </Path.Data>
                                        </Path>
                                    </Canvas>
                                </Canvas>
                                <ControlTemplate.Triggers>
                                    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                        <BeginStoryboard Storyboard="{StaticResource SpinAnimation}"/>
                                    </EventTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>